package com.ds.esd.formula.menu;

import com.ds.esd.custom.nav.menubar.NavMenuBarAnnotation;
import com.ds.esd.tool.ui.component.list.TreeListItem;
import com.ds.esd.tool.ui.enums.ItemType;

import java.util.HashMap;


@NavMenuBarAnnotation
public class FormulaPluginMenuItem extends TreeListItem {
    public FormulaPluginMenuItem() {

        this.setId("fomulaManager");
        this.setCaption("表达式管理");
        TreeListItem formulaItem = new TreeListItem();
        formulaItem.setCaption("通用权限");
        formulaItem.setId("customFormla");
        formulaItem.setImageClass("bpmfont bpmgongzuoliuxitongpeizhi");

        FormulaCustomPlugins[] menuTypes = FormulaCustomPlugins.values();

        for (FormulaCustomPlugins menuType : menuTypes) {
            formulaItem.addChild(new FormulaPluginMenuItem(menuType));
        }
        this.addChild(formulaItem);

        TreeListItem eventformulaItem = new TreeListItem();
        eventformulaItem.setCaption("事件表达式");
        eventformulaItem.setId("eventFormla");
        eventformulaItem.setImageClass("spafont spa-icon-event");

        FormulaEventPlugins[] eventmenuTypes = FormulaEventPlugins.values();

        for (FormulaEventPlugins menuType : eventmenuTypes) {
            eventformulaItem.addChild(new FormulaPluginMenuItem(menuType));
        }
        this.addChild(eventformulaItem);


        TreeListItem pageformulaItem = new TreeListItem();
        pageformulaItem.setCaption("页面表达式");
        pageformulaItem.setId("pageFormla");
        pageformulaItem.setImageClass("spafont spa-icon-page");

        FormulaPagePlugins[] pagemenuTypes = FormulaPagePlugins.values();

        for (FormulaPagePlugins menuType : pagemenuTypes) {
            pageformulaItem.addChild(new FormulaPluginMenuItem(menuType));
        }
        this.addChild(pageformulaItem);

    }


    public FormulaPluginMenuItem(ItemType menuType) {
        this.caption = menuType.getCaption();
        this.setImageClass(menuType.getImageClass());
        this.setId(menuType.getId());
        this.setIniFold(false);
        this.setEuClassName(menuType.getClassName());
        this.tagVar = new HashMap<>();
        this.tagVar.put("baseType", menuType.getId());

    }

    public FormulaPluginMenuItem(FormulaCustomPlugins menuType) {
        this.caption = menuType.getCaption();
        this.setImageClass(menuType.getImageClass());
        this.setId(menuType.getId());
        this.setIniFold(false);
        this.setEuClassName(menuType.getClassName());
        this.tagVar = new HashMap<>();
        this.tagVar.put("baseType", menuType.getId());

    }


}
